#!/bin/bash

CURRDIR=$(realpath $(dirname $0))

echo '== Basic info:'

if [ -f "${CURRDIR}/run/running_containers" ]; then
	echo 'Status: Running'
	echo "Drone URL: $(cat ${CURRDIR}/run/tunneling_url)"
else
	echo 'Status: Stopped'
fi

if [ -f "${CURRDIR}/config.sh" ]; then
	echo 'Config present: Yes'
	source "${CURRDIR}/config.sh"
	if [ -z "$REPO_PROVIDER" ]; then
		echo "(Error: Outdated config. Please check 'Troubleshooting' section of docs/config.md to update it.)"
	else
		echo "Repo provider: $REPO_PROVIDER"
		echo "Repo server: $REPO_SERVER"
		echo "Repo username: $REPO_USERNAME"
	fi
else
	echo 'Config present: No'
fi

echo '== Running containers:'
if [ -f "${CURRDIR}/run/running_containers" ]; then
	cat "${CURRDIR}/run/running_containers"
else
	echo '(No containers running)'
fi
